package server.container;

import server.pojo.Request;
import server.pojo.Response;
import server.servlet.HttpServlet;

public class MyWrapper implements BaseContainer {

    HttpServlet httpServlet;
    MyContext myContext;

    // key 字节码 文件的完全限定名
    public MyWrapper(MyContext myContext, String key) {
        myContext.add(this, key);
    }

    public void bindServlet(HttpServlet httpServlet) {
        this.httpServlet = httpServlet;
    }

    public void invoke(Request request, Response response) {
        if (httpServlet == null)
            throw new RuntimeException("no servlet plsease check");

        System.out.println("serverName: " + request.getServletName());
        httpServlet.doService(request, response);
    }


}
